package ejemplosAR;

import processing.core.PApplet;
import processing.core.PImage;
import processing.video.*;
import jp.nyatla.nyar4psg.*;

public class ImagePickup extends PApplet{

	private static final long serialVersionUID = 1L;
	private static final String PARA = "/Users/marthagarzon/Desktop/Juan Manuel/Workspace/ModuloSimulacion/data/camera_para.dat";
	private static final String HIRO = "/Users/marthagarzon/Desktop/Juan Manuel/Workspace/ModuloSimulacion/data/patt.hiro";
	
	private Capture cam;
	private MultiMarker nya;

	public void setup() {
		size(640,480,P3D);
		colorMode(RGB, 100);
		println(MultiMarker.VERSION);
		cam=new Capture(this,640,480);
		
		nya=new MultiMarker(this,width,height,PARA,NyAR4PsgConfig.CONFIG_PSG);
		nya.addARMarker(HIRO,80);//id=0
	}

	int c=0;
	public void draw()
	{
		c++;
		if (cam.available()) {
			cam.read();
			nya.detect(cam);
			background(0);
			nya.drawBackground(cam);
			if((nya.isExistMarker(0))){
				//PImage pm=nya.pickupRectMarkerImage(0,-40,-40,80,80,100,100);
				PImage pm=nya.pickupMarkerImage(0,40,40,-40,40,-40,-40,40,-40,100,100);
				image(pm,0,0);
			}
		}
	}
}